home *** CD-ROM | disk | FTP | other *** search
-
-
-
- RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((3333CCCC++++++++)))) RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((3333CCCC++++++++))))
-
-
-
- NNNNaaaammmmeeee
- RWLocaleSnapshot - Rogue Wave library class
-
- SSSSyyyynnnnooooppppssssiiiissss
- #include <locale.h>
-
-
-
- #include <rw/locale.h>
- RWLocaleSnapshot ourLocale(""); // encapsulate user's formats
-
-
-
-
- DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
- The class RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt implements the RRRRWWWWLLLLooooccccaaaalllleeee interface using
- Standard C library facilities. To use it, the program creates an
- RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt instance. The constructor of the instance queries the
- program's environment (using standard C library functions such as
- llllooooccccaaaalllleeeeccccoooonnnnvvvv(((()))), ssssttttrrrrffffttttiiiimmmmeeee(((()))), and, if available , vendor specific library
- functions) to learn everything it can about formatting conventions in
- effect at the moment of instantiation. When done, the locale can then be
- switched and another instance of RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt created. By creating
- multiple instances of RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt, your program can have more than
- one locale active at the same time, something that is difficult to do
- with the Standard C library facilities. NNNNooootttteeee: RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt does not
- encapsulate character set, collation, or message information. Class
- RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt has a set of public data members initialized by its
- constructor with information extracted from its execution environment.
-
- PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
- None
-
- EEEExxxxaaaammmmpppplllleeee
- Try this program with the environmental variable LLLLAAAANNNNGGGG set to various
- locales:
-
- #include <rw/rwdate.h>
-
-
-
- #include <rw/locale.h>
- #include <iostream.h>
-
-
- main(){
-
-
-
- RWLocaleSnapshot *userLocale = new RWLocaleSnapshot("");
- RWLocale::global(userLocale);
- // Print a number using the global locale:
-
-
-
- PPPPaaaaggggeeee 1111
-
-
-
-
-
-
- RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((3333CCCC++++++++)))) RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((3333CCCC++++++++))))
-
-
-
- cout << RWLocale::global().asString(1234567.6543) << endl;
- // Now get and print a date:
- cout << "enter a date: " << flush;
- RWDate date;
- cin >> date;
- if (date.isValid())
- cout << date << endl;
- else
- cout << "bad date" << endl;
- delete userLocale;
- return 0;
- }
-
- EEEEnnnnuuuummmmeeeerrrraaaattttiiiioooonnnnssss
- enum
- RRRRWWWWDDDDaaaatttteeeeOOOOrrrrddddeeeerrrr { DMY, MDY, YDM, YMD };
-
-
-
- PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr
- RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt(const char* localeName = 0);
-
-
- Constructs an RRRRWWWWLLLLooooccccaaaalllleeee object by extracting formats from the global
- locale environment. It uses the Standard C Library function sssseeeettttllllooooccccaaaalllleeee(((())))
- to set the named locale, and then restores the previous global locale
- after formats have been extracted. If llllooooccccaaaalllleeeeNNNNaaaammmmeeee is 0, it simply uses
- the current locale. The most useful locale name is the empty string, "",
- which is a synonym for the user's chosen locale (usually specified by the
- environment variable LLLLAAAANNNNGGGG).
-
- PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
- virtual RWCString
- aaaassssSSSSttttrrrriiiinnnngggg(long) const;
- virtual RWCString
- aaaassssSSSSttttrrrriiiinnnngggg(unsigned long) const;
- virtual RWCString
- aaaassssSSSSttttrrrriiiinnnngggg(double f, int precision = 6,
- RWBoolean showpoint = 0) const;
- virtual RWCString
- aaaassssSSSSttttrrrriiiinnnngggg(struct tm* tmbuf,char format, const RWZone& zone);
- const;
- virtual RWCString
- aaaassssSSSSttttrrrriiiinnnngggg(struct tm* tmbuf,char* format,
- const RWZone& zone) const;
- virtual RWCString
- mmmmoooonnnneeeeyyyyAAAAssssSSSSttttrrrriiiinnnngggg(double value,enum CurrSymbol = LOCAL) const;
- virtual RWBoolean
- ssssttttrrrriiiinnnnggggTTTTooooNNNNuuuummmm (const RWCString&, double* fp) const;
- virtual RWBoolean
- ssssttttrrrriiiinnnnggggTTTTooooNNNNuuuummmm (const RWCString&, long* ip ) const;
- virtual RWBoolean
-
-
-
- PPPPaaaaggggeeee 2222
-
-
-
-
-
-
- RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((3333CCCC++++++++)))) RRRRWWWWLLLLooooccccaaaalllleeeeSSSSnnnnaaaappppsssshhhhooootttt((((3333CCCC++++++++))))
-
-
-
- ssssttttrrrriiiinnnnggggTTTTooooDDDDaaaatttteeee (const RWCString&, struct tm*) const;
- virtual RWBoolean
- ssssttttrrrriiiinnnnggggTTTTooooTTTTiiiimmmmeeee (const RWCString&, struct tm*) const;
- virtual RWBoolean
- ssssttttrrrriiiinnnnggggTTTTooooMMMMoooonnnneeeeyyyy(const RWCString&, double* ,
- RWLocale::CurrSymbol=LOCAL) const;
-
-
- Redefined from class RRRRWWWWLLLLooooccccaaaalllleeee. These virtual functions follow the
- interface described under class RRRRWWWWLLLLooooccccaaaalllleeee. They generally work by
- converting values to and from strings using the rules specified by the
- ssssttttrrrruuuucccctttt llllccccoooonnnnvvvv values (see <<<<llllooooccccaaaalllleeee....hhhh>>>>) encapsulated in self.
-
- PPPPuuuubbbblllliiiicccc DDDDaaaattttaaaa MMMMeeeemmmmbbbbeeeerrrrssss
- RWCString decimal_point_;
- RWCString thousands_sep_;
- RWCString grouping_;
- RWCString int_curr_symbol_;
- RWCString currency_symbol_;
- RWCString mon_decimal_point_;
- RWCString mon_thousands_sep_;
- RWCString mon_grouping_;
- RWCString positive_sign_;
- RWCString negative_sign_;
- char int_frac_digits_;
- char frac_digits_;
- char p_cs_precedes_;
- char p_sep_by_space_;
- char n_cs_precedes_;
- char n_sep_by_space_;
- char p_sign_posn_;
- char n_sign_posn_;
-
-
- These are defined identically as the correspondingly-named members of the
- standard C library type llllccccoooonnnnvvvv, from <<<<llllooooccccaaaalllleeee....hhhh>>>>.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PPPPaaaaggggeeee 3333
-
-
-
-